const { MongoClient, ServerApiVersion } = require("mongodb");
const url =
  "mongodb+srv://2815473064:1540306541@cluster0.v3deufj.mongodb.net/?retryWrites=true&w=majority";
const client = new MongoClient(url, {
  serverApi: {
    version: ServerApiVersion.v1,
    strict: true,
    deprecationErrors: true,
  },
});
async function run() {
  try {
    // Connect the client to the server	(optional starting in v4.7)
    await client.connect();
    // Send a ping to confirm a successful connection
    await client.db("admin").command({ ping: 1 });
    console.log(
      "Pinged your deployment. You successfully connected to MongoDB!"
    );
  } catch (error) {
      console.log(error);
      console.log("操作失败");
  }finally {
      
    // Ensures that the client will close when you finish/error
    await client.close();
  }
}
run().catch(console.dir);
